package com.baselibrary.router;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;

import androidx.core.app.ActivityOptionsCompat;
import androidx.core.util.Pair;

import com.alibaba.android.arouter.launcher.ARouter;
import com.baselibrary.utils.CommonUtil;

/**
 * @author zhanglijie
 * @date 20-3-2
 * @Description
 */
public class ActivityRouter {

    public static final class LoggingInterceptor {
        public static final String INTERCEPTOR = "/interceptor/initLog";
    }

    public static final class ACTIVITY {
        public static final String MAIN_PAGE = "/Main/FirstType";
        public static final String SPLASH = "/app/splash";
        public static final String SEARCH_ALL = "/search/all";
        public static final String WEB_VIEW = "/web/view";
        public static final String IMAGE_DETAIL = "/image/detail";
        public static final String READ_VIDEO_DETAIL = "/revision/videoRead";
        public static final String BANNER_INFO = "/home/bannerInfo";
        public static final String NATIVE_HELP = "/native/help";
        public static final String SHARE_HELP = "/share/help";
        public static final String BROWSE_MEDIA = "/commons/browseMedia";
        //海报分享
        public static final String SHARE_POSTER = "/common/sharePoster";

        public static final String SHARE_POSTER_SELECT = "/commons/sharePosterSelect";
        public static final String SHARE_POSTER_SHOW = "/common/sharePosterShow";
        //H5webviewActivity
        public static final String ACTIVE_H5_WEB_VIEW = "/active/h5webView";
        //文化大使投票海报
        public static final String H5_SHARE_VOTERANK = "/active/h5ShareVoterank";
        //AlbumWebViewActivity
        public static final String ACTIVE_ALBUM_WEB_VIEW = "/active/albumWebViewActivity";
        //直播详情页
        public static final String ACTIVE_LIVE_PLAYER = "/active/livePlayer";
        //直播信息页
        public static final String ACTIVE_LIVE_INFO = "/active/liveInfo";
        //举报
        public static final String REPORT = "/app/report";
        //引导页
        public static final String GUIDE = "/app/guide";
    }

    public static final class MATERIAL {
        public static final String HOME_PAGE = "/NewMaterial/MaterialHome";
        //新版素材库【搜索】
        public static final String SEARCH = "/NewMaterial/search";
        //新版素材库【文档详情】
        public static final String DOCUMENT_DETAIL = "/NewMaterial/documentDetail";
        //内容列表页
        public static final String MATERIAL_CONTENT_LIST = "/NewMaterial/contentList";
        //创建文件夹
        public static final String MATERIAL_CREATE_FOLDER = "/NewMaterial/createFolder";
        //文件夹列表
        public static final String MATERIAL_COLLECTION_FOLDER = "/NewMaterial/collectionFolder";
        //下载列表（下载中/已完成）
        public static final String MATERIAL_DOWNLOAD_MAIN = "/NewMaterial/downloadList";

    }

    //0元购
    public static final class ZERO_BUY {
        //砍价、参与 页面
        public static final String ACTIVE_PAGE = "/zeroBuy/activePage";
        //0元购首页
        public static final String ACTIVE_SHOP_HOME = "/zeroBuy/shopHome";
        //我的砍价购订单界面
        public static final String ACTIVE_SHOP_ORDER = "/zeroBuy/bargainOrder";

        public static final String ACTIVE_SHOP_HELP = "/app/shopHelp";
    }

    //个人中心
    public static final class MINE_CENTER {
        //子moudle 调用 app
        public static final String MINE_HELP = "/feature_mine/Help";
        //用户主页
        public static final String USER_INFO = "/Mine/PersonalCenter";
        //关注和粉丝和好友
        public static final String MINE_ATTENTIVE = "/Mine/Attentive";
        //我的酒币 列表
        public static final String MY_COIN_LIST = "/Mine/MyCoin";
        //我预约的直播
        public static final String MY_SUBSCRIBE_LIVE = "/User/MySubscribeLive";
        //酣粉证
        public static final String HAN_FANS_CARD = "/User/fansCard";
        //健康数据
        public static final String HEALTH_DATA = "/User/HealthData";
        //粉丝中心
        public static final String FANS_CENTER = "/User/FansCenter";
        //设置
        public static final String SETTING = "/Mine/Setting";
        //公文政策
        public static final String DOCUMENT_WEB = "/User/DocumentWeb";
        //打开客服
        public static final String CUSTOMER_SERVICE = "/User/CustomerService";
        //编辑信息
        public static final String MINE_EDIT_INFO = "/User/EditInformation";
        //消息设置（推送开关）
        public static final String MESSAGE_SET = "/Mine/MessageSet";
        //粉丝礼包里面的内容
        public static final String FANS_CONTENT = "/User/fansContent";
        //老王的来信内容
        public static final String FROM_LETTER_CONTENT = "/User/fromLetter";
        //入库申请
        public static final String USE_STATISTICS_APPLY = "/Mine/useStatisticsApply";
        //领用申请
        public static final String USE_STATISTICS_INTO_DATA = "/Mine/useStatisticsIntoData";
        //入库列表
        public static final String USE_STATISTICS_LIST = "/Mine/useStatisticsList";
        //入库详情
        public static final String USE_STATISTICS_DETAIL = "/Mine/useStatisticsDetail";
        //库存统计
        public static final String STOCK_STATISTICS = "/Mine/stockStatistics";
        //渠道中心
        public static final String CHANNEL_CENTER = "/Mine/channelCenter";
        //渠道中心--拜访记录
        public static final String CALL_RECORD = "/Mine/callRecord";
        //渠道中心--添加拜访/回访
        public static final String ADD_VISIT = "/Mine/addVisit";
        //渠道中心--拜访/回访草稿
        public static final String VISIT_DRAFT_LIST = "/Mine/visitDraftList";
        //渠道中心--回访/拜访详情
        public static final String VISIT_DETAIL = "/Mine/visitDetail";
        //我的奖品
        public static final String MY_PRIZES_LIST = "/Mine/myPrizes";
        //奖品详情
        public static final String PRIZE_DETAIL = "/Mine/prizeDetail";
    }

    //登录
    public static final class LOGIN {
        //子moudle 调用 app
        public static final String LOGIN_HELP = "/feature_login/help";
        //登录页
        public static final String LOGIN_PAGE = "/user/loginPage";
        //忘记密码
        public static final String FORGET_PWD_PAGE = "/logins/forgetPwdPage";
        //短信验证  输入验证码
        public static final String FORGET_PWD_AUTH_PAGE = "/logins/forgetPwdAuthPage";
        //忘记密码重置密码
        public static final String FORGET_PWD_RESET_PAGE = "/logins/forgetPwdResetPage";

    }

    //消息
    public static final class MESSAGE {
        public static final String MESSAGE_HELP = "/feature_message/help";
        //点赞和收藏
        public static final String LIKE_AND_COLLECT = "/msg/likeAndCollect";
        //评论我的
        public static final String COMMENT_ME = "/msg/commentMe";
        //广播 列表
        public static final String SYSTEM_MESSAGE_LIST = "/msg/systemList";
        //消息主页
        public static final String MESSAGE_MAIN_PAGE = "/msg/homePage";
    }

    //社区
    public static final class COMMUNITY {
        //社区
        public static final String COMMUNITY_HELP = "/feature_community/help";
        //选择好友
        public static final String COMMUNITY_SELECTED_FRIEND = "/communitys/selectedFriend";
        //直接分享给好友
        public static final String COMMUNITY_SHARE_FRIEND = "/communitys/shareFriend";

        //话题详情
        public static final String COMMUNITY_TOPIC_DETAIL = "/communitys/topicDetail";

        //话题内容详情
        public static final String COMMUNITY_TOPIC_CONTENT_DETAIL = "/communitys/topicContentDetail";

        //优质用户列表
        public static final String COMMUNITY_TOPIC_GOOD_USER = "/communitys/topicGoodUser";

        //话题搜索页
        public static final String COMMUNITY_TOPIC_SEARCH = "/communitys/topicSearch";
        //讲坛分类 列表页
        public static final String FORUM_CLASSIFY = "/communitys/forumClassify";
        //专栏详情
        public static final String COLUMN_DETAIL = "/communitys/columnDetail";
        //文章详情
        public static final String ARTICLE_DETAIL = "/communitys/articleDetails";
        //百科详情
        public static final String WIKI_DETAIL = "/community/wikiDetails";
        //讲坛主页
        public static final String COMMUNITY_PULPITHOME = "/communitys/pulpitHome";
        //讲坛视频详情
        public static final String COMMUNITY_PULPIT_VIDEO = "/communitys/pulpitVideo";
        //讲坛列表
        public static final String FORUM_LIST = "/communitys/forumList";
        //专栏列表
        public static final String COLUMN_LIST = "/communitys/columnList";
        //百科 列表
        public static final String WIKI_LIST = "/communitys/wikiList";
        //下酒菜主页
        public static final String WINERY_FOOD = "/communitys/wineryFood";
        //全部话题
        public static final String ALL_TOPIC = "/communitys/allTopic";
        //话题分类
        public static final String TOPIC_CLASSIFY = "/communitys/topicClassify";
    }


    public static final class COMMENT {
        //评论
        public static final String COMMENT_HELP = "/comment/help";
    }

    public static final class WINE_MEAL {
        //时令美食
        public static final String WINE_MEAL_FINE_FOOD = "/foodStalls/fineFood";
        //下酒菜详情
        public static final String WINE_MEAL_DETAILS = "/foodStalls/foodMenuDetail";
        //分享海报
        public static final String WINE_MEAL_POSTER = "/foodStalls/poster";

        public static final String WINE_MEAL_HELP = "/food/help";

        //介绍页
        public static final String WINE_MEAL_INTRO = "/foodStalls/foodIntro";
    }

    //酒窖
    public static final class WINE_CELLAR {
        //
        public static final String WINE_CELLAR_HELP = "/feature_wine_cellar/help";
        //酒窖详情
        public static final String WINCE_CELLAR_DETAIL = "/wineCellar/detail";
        //酒窖信息详情
        public static final String WINCE_CELLAR_INFO = "/wineCellar/info";
        //经营者中心
        public static final String WINCE_CELLAR_MANAGER_CENTER = "/wineCellar/managerCenter";
        //线上酒窖管理
        public static final String WINCE_ONLINE_WINCELLAR_MANAGER = "/wineCellar/onlineManager";
        //酒窖评论管理
        public static final String WINCE_COMMENT_MANAGER = "/wineCellar/commentManage";
        //全部评价
        public static final String ALL_EVALUATE = "/wineCellar/allEvaluate";
        //发布酒窖评论
        public static final String PUBLISH_WINEECELLAR_COMMEENT = "/wineCellar/publishCommeent";
        //线上酒窖编辑
        public static final String EDIT_ONLINE_WINCELLAR = "/wineCellar/edit";
        //私房菜管理
        public static final String WINCE_PRIVATE_MEAL_MANAGER = "/wineCellar/privateMeslMagage";
        //酒窖动态管理
        public static final String WINCE_DYNAMIC_MANAGER = "/wineCellar/dynamicMagage";
        //发布下酒菜
        public static final String PUBLISH_PRIVATE_MEAL = "/wineCellar/publishPrivateMeal";
        //图片、视频详情 带评论文字
        public static final String IMG_VIDEO_DETAIL = "/wineCellar/imgVideDetail";
        //分享-酒窖详情海报
        public static final String SHARE_POSTER = "/wineCellar/sharePoster";
        //新零售-二期-商品管理
        public static final String GOODS_MANAGER = "/wineCellar/goodsManager";
        //新零售-二期-销售订单
        public static final String SALE_ORDER = "/wineCellar/saleOrder";
        //新零售-二期-售后列表
        public static final String AFTER_SALE_LIST = "/wineCellar/afterSaleOrder";
        //新零售-二期-经营者-售后详情
        public static final String AFTER_SALE_DETAIL = "/wineCellar/afterSaleOrderDetail";
        //新零售-二期-订单详情 （经营者身份，只可观看，不可操作）
        public static final String ORDER_DETAIL = "/wineCellar/orderDetail";
        //搜索订单
        public static final String SEARCH_ORDER = "/wineCellar/searchOrder";
        //酒窖-搜索地址
        public static final String WINERY_SEARCH_ADDRESS = "/wineCellar/searchAddress";
        //选择城市
        public static final String WINERY_SELECT_CITY = "/wineCellar/selectCity";
        //酒窖全部动态 列表
        public static final String WINCE_ALL_DYNAMIC = "/wineCellar/allDynamicList";
        //酒窖全部秒杀 列表
        public static final String WINCE_ALL_SECKILL = "/wineCellar/allSeckillList";
    }

    //新零售
    public static final class NEW_RETAIL {
        public static final String NEW_RETAIL_HELP = "/feature_newretail/help";
        //确认订单
        public static final String CONFIRM_ORDER = "/newRetail/confirmOrder";
        //支付成功
        public static final String PAY_SUCCESS = "/newRetail/paySuccess";
        //收货地址
        public static final String RECEIVE_ADDRESS = "/newRetail/receiveAddress";
        //编辑&添加地址
        public static final String EDIT_OR_ADD_NEW_ADDRESS = "/newRetail/editOrAddNewAddress";
        //选择支付方式
        public static final String SELECT_PAY_WAY = "/newRetail/selectPayWay";
        //商品详情
        public static final String GOODS_DETAUILS = "/newRetail/goodsDetails";
        //购物车
        public static final String SHOP_CART = "/newRetail/shopCart";
        //我的订单
        public static final String MY_ORDER = "/newRetail/myOrder";
        //订单详情
        public static final String ORDER_DETAIL = "/newRetail/orderDetail";
        //物流
        public static final String MY_LOGISTICS = "/newRetail/logistics";
        //售后列表
        public static final String RETAIL_AFTER_SALES = "/newRetail/afterSales";
        //售后申请
        public static final String AFTER_SALES_APPLY = "/newRetail/afterSalesApply";
        //售后详情
        public static final String AFTER_SALES_DETAILS = "/newRetail/AfterSalesDetails";
        //全部评价
        public static final String ALL_APPRAISE = "/newRetail/allAppraise";
        //评价中心
        public static final String EVALUATION_CENTER = "/newRetail/evaluationCenter";
        //评价详情
        public static final String EVALUATION_DETAIL = "/newRetail/evaluationDetail";
        //发表评价
        public static final String PUBLISH_EVALUATION = "/newRetail/publishEvaluation";
        //全部商品
        public static final String ALL_GOODS = "/newRetail/allGoods";
        //秒杀
        public static final String SECKILL = "/newRetail/seckill";

    }

    public static <T> T getARouterInterface(String path) {
        return (T) ARouter.getInstance().build(path).navigation();
    }

    public static void startActivity(String path, Bundle bundle) {
        ARouter.getInstance().build(path).with(bundle).navigation();
    }

    /**
     * 有共享元素动画的跳转
     *
     * @param path
     * @param bundle
     * @param view
     */
    public static void startActivity(String path, Bundle bundle, View view) {
        try {
            if (CommonUtil.getCurrentActivity() != null) {
                ActivityOptionsCompat aoc = ActivityOptionsCompat.makeSceneTransitionAnimation(CommonUtil.getCurrentActivity(), new Pair(view, "DynamicShareElement"));
                ARouter.getInstance().build(path).with(bundle).withOptionsCompat(aoc).navigation(CommonUtil.getCurrentActivity());
            } else {
                ARouter.getInstance().build(path).with(bundle).navigation();
            }
        } catch (Exception e) {
            e.printStackTrace();
            ARouter.getInstance().build(path).with(bundle).navigation();
        }
    }

    public static void startActivity(String path, Bundle bundle, int flag) {
        ARouter.getInstance().build(path).withFlags(flag).with(bundle).navigation();
    }

    public static void startActivity(String path) {
        ARouter.getInstance().build(path).navigation();
    }

    public static void startActivityForResult(Activity context, String path, Bundle bundle) {
        startActivityForResult(context, path, bundle, 2);
    }

    public static void startActivityForResult(Activity context, String path, Bundle bundle, int requestCode) {
        ARouter.getInstance().build(path).with(bundle).navigation(context, requestCode);
    }
}
